/** EasyWeb iframe v3.1.5 date:2019-10-05 License By http://easyweb.vip */
layui.define(["layer", "element", "admin"], function(s) {
  var $ = layui.jquery;
  var layer = layui.layer;
  var element = layui.element;
  var admin = layui.admin;
  var a = ".layui-layout-admin>.layui-header";
  var o = ".layui-layout-admin>.layui-side>.layui-side-scroll";
  var j = ".layui-layout-admin>.layui-body";
  var n = j + ">.layui-tab";
  var q = j + ">.layui-body-header";
  var i = "admin-pagetabs";
  var layadminSideNav = "admin-side-nav";
  var k = {};
  var f = false;
  var c;
  var index = {
      pageTabs: true,
      cacheTab: true,
      openTabCtxMenu: true,
      maxTabNum: 20,
      mTabList: [],
      mTabPosition: undefined,
      loadView: function(y) {
          var w = y.menuPath;
          var v = y.menuName;
          if (!w) {
              console.error("url不能为空");
              layer.msg("url不能为空", {
                  icon: 2
              });
              return
          }
          if (index.pageTabs) {
              var u = false;
              $(n + ">.layui-tab-title>li").each(function() {
                  if ($(this).attr("lay-id") === w) {
                      u = true;
                      return false
                  }
              });
              if (!u) {
                  if ((index.mTabList.length + 1) >= index.maxTabNum) {
                      layer.msg("最多打开" + index.maxTabNum + "个选项卡", {
                          icon: 2
                      });
                      admin.activeNav(index.mTabPosition);
                      return
                  }
                  f = true;
                  element.tabAdd(i, {
                      id: w,
                      title: '<span class="title">' + (v ? v : "") + "</span>",
                      content: '<iframe lay-id="' + w + '" src="' + w + '" frameborder="0" class="admin-iframe"></iframe>'
                  });
                  if (w != c) {
                      index.mTabList.push(y)
                  }
                  if (index.cacheTab) {
                      admin.putTempData("indexTabs", index.mTabList)
                  }
              }
              element.tabChange(i, w)
          } else {
              var t = $(j + ">.admin-iframe");
              if (!t || t.length <= 0) {
                  var x = '<div class="layui-body-header">';
                  x += '      <span class="layui-body-header-title"></span>';
                  x += '      <span class="layui-breadcrumb pull-right">';
                  x += '         <a ew-href="' + c + '">首页</a>';
                  x += "         <a><cite></cite></a>";
                  x += "      </span>";
                  x += "   </div>";
                  x += '   <div style="-webkit-overflow-scrolling: touch;">';
                  x += '      <iframe lay-id="' + w + '" src="' + w + '" frameborder="0" class="admin-iframe"></iframe>';
                  x += "   </div>";
                  $(j).html(x);
                  if (w != c) {
                      index.setTabTitle(v)
                  }
                  element.render("breadcrumb")
              } else {
                  t.attr("lay-id", w);
                  t.attr("src", w);
                  index.setTabTitle(v)
              }
              admin.activeNav(w);
              index.mTabList.splice(0, index.mTabList.length);
              if (w != c) {
                  index.mTabList.push(y);
                  index.mTabPosition = w
              } else {
                  index.mTabPosition = undefined
              } if (index.cacheTab) {
                  admin.putTempData("indexTabs", index.mTabList);
                  admin.putTempData("tabPosition", index.mTabPosition)
              }
          } if (admin.getPageWidth() <= 768) {
              admin.flexible(true)
          }
      },
      loadHome: function(v) {
          c = v.menuPath;
          var w = admin.getTempData("indexTabs");
          var t = admin.getTempData("tabPosition");
          var u = (v.loadSetting == undefined ? true : v.loadSetting);
          index.loadView({
              menuPath: c,
              menuName: v.menuName
          });
          if (!index.pageTabs) {
              admin.activeNav(v.menuPath)
          }
          if (u) {
              index.loadSettings(w, t, v.onlyLast)
          }
      },
      openTab: function(v) {
          if (window != top && !admin.isTop()) {
              if (top.layui && top.layui.index) {
                  top.layui.index.openTab(v);
                  return
              }
          }
          var t = v.url;
          var u = v.title;
          if (v.end) {
              k[t] = v.end
          }
          index.loadView({
              menuPath: t,
              menuName: u
          })
      },
      closeTab: function(t) {
          if (window != top && !admin.isTop()) {
              if (top.layui && top.layui.index) {
                  top.layui.index.closeTab(t);
                  return
              }
          }
          element.tabDelete(i, t)
      },
      loadSettings: function(z, y, w) {
          if (index.cacheTab) {
              var A = z;
              var v = y;
              if (A) {
                  var u = -1;
                  for (var x = 0; x < A.length; x++) {
                      if (index.pageTabs && !w) {
                          index.loadView(A[x])
                      }
                      if (A[x].menuPath == v) {
                          u = x
                      }
                  }
                  if (u != -1) {
                      setTimeout(function() {
                          index.loadView(A[u]);
                          if (!index.pageTabs) {
                              admin.activeNav(v)
                          }
                      }, 150)
                  }
              }
          }
          var t = layui.data(admin.tableName);
          if (t) {
              if (t.openFooter != undefined && t.openFooter == false) {
                  $("body.layui-layout-body").addClass("close-footer")
              }
              if (t.tabAutoRefresh) {
                  $(n).attr("lay-autoRefresh", "true")
              }
              if (t.navArrow != undefined) {
                  $(o + ">.layui-nav-tree").removeClass("arrow2 arrow3");
                  t.navArrow && $(o + ">.layui-nav-tree").addClass(t.navArrow)
              }
          }
      },
      setTabCache: function(t) {
          if (window != top && !admin.isTop()) {
              if (top.layui && top.layui.index) {
                  top.layui.index.setTabCache(t);
                  return
              }
          }
          layui.data(admin.tableName, {
              key: "cacheTab",
              value: t
          });
          index.cacheTab = t;
          if (t) {
              admin.putTempData("indexTabs", index.mTabList);
              admin.putTempData("tabPosition", index.mTabPosition)
          } else {
              admin.putTempData("indexTabs", []);
              admin.putTempData("tabPosition", undefined)
          }
      },
      clearTabCache: function() {
          admin.putTempData("indexTabs", undefined)
      },
      setTabTitle: function(u, t) {
          if (window != top && !admin.isTop()) {
              if (top.layui && top.layui.index) {
                  top.layui.index.setTabTitle(u, t);
                  return
              }
          }
          if (!index.pageTabs) {
              if (u) {
                  $(q).addClass("show");
                  var v = $(q + ">.layui-body-header-title");
                  v.html(u);
                  v.next(".layui-breadcrumb").find("cite").last().text(u)
              } else {
                  $(q).removeClass("show")
              }
          } else {
              u || (u = "");
              t || (t = $(n + ">.layui-tab-title>li.layui-this").attr("lay-id"));
              t && $(n + '>.layui-tab-title>li[lay-id="' + t + '"] .title').html(u)
          }
      },
      setTabTitleHtml: function(t) {
          if (window != top && !admin.isTop()) {
              if (top.layui && top.layui.index) {
                  top.layui.index.setTabTitleHtml(t);
                  return
              }
          }
          if (!index.pageTabs) {
              if (t) {
                  $(q).addClass("show");
                  $(q).html(t)
              } else {
                  $(q).removeClass("show")
              }
          }
      },
      closeTabCache: function() {
          console.warn("closeTabCache() has been deprecated, please use clearTabCache().");
          index.clearTabCache()
      },
      loadSetting: function() {
          console.warn("loadSetting() has been deprecated.")
      }
  };
  var l = layui.data(admin.tableName);
  if (l) {
      if (l.openTab != undefined) {
          index.pageTabs = l.openTab
      }
      if (l.cacheTab != undefined) {
          index.cacheTab = l.cacheTab
      }
  }
  var g = ".layui-layout-admin .site-mobile-shade";
  if ($(g).length <= 0) {
      $(".layui-layout-admin").append('<div class="site-mobile-shade"></div>')
  }
  $(g).click(function() {
      admin.flexible(true)
  });
  if (index.pageTabs && $(n).length <= 0) {
      var e = '<div class="layui-tab" lay-allowClose="true" lay-filter="admin-pagetabs">';
      e += '       <ul class="layui-tab-title"></ul>';
      e += '      <div class="layui-tab-content"></div>';
      e += "   </div>";
      e += '   <div class="layui-icon admin-tabs-control layui-icon-prev" ew-event="leftPage"></div>';
      e += '   <div class="layui-icon admin-tabs-control layui-icon-next" ew-event="rightPage"></div>';
      e += '   <div class="layui-icon admin-tabs-control layui-icon-down">';
      e += '      <ul class="layui-nav admin-tabs-select" lay-filter="admin-pagetabs-nav">';
      e += '         <li class="layui-nav-item" lay-unselect>';
      e += "            <a></a>";
      e += '            <dl class="layui-nav-child layui-anim-fadein">';
      e += '               <dd ew-event="closeThisTabs" lay-unselect><a>关闭当前标签页</a></dd>';
      e += '               <dd ew-event="closeOtherTabs" lay-unselect><a>关闭其它标签页</a></dd>';
      e += '               <dd ew-event="closeAllTabs" lay-unselect><a>关闭全部标签页</a></dd>';
      e += "            </dl>";
      e += "         </li>";
      e += "      </ul>";
      e += "   </div>";
      $(j).html(e);
      element.render("nav")
  }
  element.on("nav(" + layadminSideNav + ")", function(w) {
      var v = $(w);
      var t = v.attr("lay-href");
      var x = v.attr("lay-id");
      if (!x) {
          x = t
      }
      if (t && t != "javascript:;") {
          var u = v.attr("ew-title");
          u || (u = v.text().replace(/(^\s*)|(\s*$)/g, ""));
          index.loadView({
              menuId: x,
              menuPath: t,
              menuName: u
          })
      }
  });
  element.on("tab(" + i + ")", function(v) {
      var u = $(this).attr("lay-id");
      if (u != c) {
          index.mTabPosition = u
      } else {
          index.mTabPosition = undefined
      } if (index.cacheTab) {
          admin.putTempData("tabPosition", index.mTabPosition)
      }
      admin.rollPage("auto");
      admin.activeNav(u);
      var t = $(n).attr("lay-autoRefresh");
      if (t === "true" && !f) {
          admin.refresh(u)
      }
      f = false
  });
  element.on("tabDelete(" + i + ")", function(v) {
      var t = index.mTabList[v.index - 1];
      if (t) {
          var u = t.menuPath;
          index.mTabList.splice(v.index - 1, 1);
          if (index.cacheTab) {
              admin.putTempData("indexTabs", index.mTabList)
          }
          if (k[u]) {
              k[u].call()
          }
      }
      if ($(n + ">.layui-tab-title>li.layui-this").length <= 0) {
          $(n + ">.layui-tab-title>li:last").trigger("click")
      }
  });
  $(document).off("click.navMore").on("click.navMore", "[nav-bind]", function() {
      var t = $(this).attr("nav-bind");
      $('ul[lay-filter="' + layadminSideNav + '"]').addClass("layui-hide");
      $('ul[nav-id="' + t + '"]').removeClass("layui-hide");
      if (admin.getPageWidth() <= 768) {
          admin.flexible(false)
      }
      $(a + ">.layui-nav .layui-nav-item").removeClass("layui-this");
      $(this).parent(".layui-nav-item").addClass("layui-this")
  });
  if (index.openTabCtxMenu && index.pageTabs) {
      layui.use("contextMenu", function() {
          var t = layui.contextMenu;
          if (t) {
              $(n + ">.layui-tab-title").off("contextmenu.tab").on("contextmenu.tab", "li", function(v) {
                  var u = $(this).attr("lay-id");
                  t.show([{
                      icon: "layui-icon layui-icon-refresh",
                      name: "刷新当前",
                      click: function() {
                          element.tabChange(i, u);
                          var w = $(n).attr("lay-autoRefresh");
                          if (!w || w !== "true") {
                              admin.refresh(u)
                          }
                      }
                  }, {
                      icon: "layui-icon layui-icon-close-fill ctx-ic-lg",
                      name: "关闭当前",
                      click: function() {
                          admin.closeThisTabs(u)
                      }
                  }, {
                      icon: "layui-icon layui-icon-unlink",
                      name: "关闭其他",
                      click: function() {
                          admin.closeOtherTabs(u)
                      }
                  }, {
                      icon: "layui-icon layui-icon-close ctx-ic-lg",
                      name: "关闭全部",
                      click: function() {
                          admin.closeAllTabs()
                      }
                  }], v.clientX, v.clientY);
                  return false
              })
          }
      })
  }
  s("index", index)
});